import { Login } from "@/api/interface/index";

import http from "@/api";
import { IUserPermission } from "@/api/interface/permission";
/**
 * @name 登录模块
 */
// * 用户登录接口
export const loginApi = (params: Login.ReqLoginForm) => {
	return http.post<Login.ResLogin>({
		url: `/auth/login`,
		data: params
	});
	// return http.post<Login.ResLogin>(`/login`, {}, { params }); // post 请求携带 query 参数  ==>  ?name=admin&password=123456
	// return http.post<Login.ResLogin>(`/login`, qs.stringify(params)); // post 请求携带 表单 参数  ==>  application/x-www-form-urlencoded
	// return http.post<Login.ResLogin>(`/login`, params, { headers: { noLoading: true } }); // 控制当前请求不显示 loading
};

// * 获取按钮权限
export const getAuthorButtons = () => {
	return http.get<Login.ResAuthButtons>({
		url: `/menu/buttons`
	});
};

// * 获取菜单列表
export const getMenuList = () => {
	return http.get<Menu.MenuOptions[]>({
		url: `/auth/getUserAllMenuList`
	});
};

// *获取用户权限表
export const getUserAllPermissionList = () => {
	return http.get<IUserPermission[]>({
		url: `/auth/getUserAllPermissionList`
	});
};
